﻿@using Entidades.Sistema.Venta
@using Entidades.Sistema.Base
@using System.Collections.ObjectModel;
@using System.Collections.Generic;

@model Entidades.Sistema.Base.Cargo
@{
    Html.EnableClientValidation();
    Html.EnableUnobtrusiveJavaScript();
}

@using (Html.BeginForm("EditCargosUpdatePartial", "Cargo", FormMethod.Post, new { @class = "edit_form", style = "height: 210px;" }))
{
    <div class="span6"> 
    <div class="BottomPadding">Datos:</div>

    @Html.Hidden("IdCargo")
    <div class="line">
        @Html.DevExpress().Label(
            settings => {
                settings.ControlStyle.CssClass = "label";
                settings.Text = "Nombre Cargo:";
                settings.AssociatedControlName = "Nombre";
            }
        ).GetHtml()
        @Html.DevExpress().TextBox(
            settings => {
                settings.Name = "Nombre";
                settings.ControlStyle.CssClass = "editor";
                settings.ShowModelErrors = true;
                settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
            }
        ).Bind(Model.Nombre).GetHtml()
        
    </div>
    
    <div class="line">
        @Html.DevExpress().Label(
            settings => {
                settings.ControlStyle.CssClass = "label";
                settings.Text = "Descripcion:";
                settings.AssociatedControlName = "editor";
            }
        ).GetHtml()
        @Html.DevExpress().TextBox(
            settings => {
                settings.Name = "Descripcion";
                settings.ControlStyle.CssClass = "Descripcion";
                settings.ShowModelErrors = true;
                settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;          
            }
        ).Bind(Model.Descripcion).GetHtml()
    </div>
    <div class="line">
        @Html.DevExpress().Label(
            settings => {
                settings.ControlStyle.CssClass = "label";
                settings.Text = "Habilitado Para Producción:";
                settings.AssociatedControlName = "HabilitadoProduccion";
            }
        ).GetHtml()
        @Html.DevExpress().CheckBox(
            settings => {
                settings.Name = "HabilitadoProduccion";
                settings.ControlStyle.CssClass = "editor";
                settings.ShowModelErrors = true;
                settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;          
            }
        ).Bind(Model.HabilitadoProduccion).GetHtml()
    </div>

    
    <div class="line">
        @Html.DevExpress().Label(
            settings => {
                settings.ControlStyle.CssClass = "label";
            }
        ).GetHtml()
        @Html.DevExpress().Button(
            settings => {
                settings.Name = "btnUpdate";
                settings.ControlStyle.CssClass = "button";
                settings.Text = "Actualizar";
                settings.UseSubmitBehavior = true;
            }
        ).GetHtml()
        @Html.DevExpress().Button(
            settings => {
                settings.Name = "btnCancel";
                settings.ControlStyle.CssClass = "button";
                settings.Text = "Cancelar";
                settings.ClientSideEvents.Click = "function(s, e){ document.location='" + DevExpressHelper.GetUrl(new { Controller = "Cargo", Action = "Index" }) + "'; }";
            }
        ).GetHtml()
    </div>
    
  </div>
     
        <div class="BottomPadding">Grupos:</div>
        @Html.DevExpress().ListBox(
        settings => {
            settings.Name = "lbModels";
            settings.CallbackRouteValues = new { Controller = "Editors", Action = "ListBoxPartial" };
            settings.Width = 300;
            settings.Height = 210;
            settings.Properties.EnableClientSideAPI = true;
            settings.Properties.SelectionMode = ListEditSelectionMode.CheckColumn;
            settings.Properties.ValueField = "IdGrupo";
            settings.Properties.TextField = "Descripcion";
            settings.Properties.ValueType = typeof(string);
            settings.PreRender = (sender, e) =>
            {
                ASPxListBox cbl = (ASPxListBox)sender;
                foreach (ListEditItem item in cbl.Items)
                {
                    if (Model.Grupos.Any(x => x.IdGrupo == item.Value.ToString()))
                        item.Selected = true;
                }
            };            
        }).BindList(ViewBag.Grupo).GetHtml()
    
}










